from selenium import webdriver
import time

class tes_tes:
    def __init__(self):
        self.driver = webdriver.Firefox()
        self.driver.maximize_window()
        self.driver.implicitly_wait(3)
        self.driver.get('http://192.168.0.235/TinyShop_v2.4/index.php?con=admin&act=login')
        lr = ['admin','123456','aaaa']
        ls = self.driver.find_elements_by_tag_name('input')
        for i in range(len(ls)):
            if ls[i].get_attribute('type') != 'submit':
                ls[i].clear()
                ls[i].send_keys(lr[i])
            else:
                ls[i].click()
                break
        self.driver.find_element_by_link_text('统计报表').click()
        # self.driver.find_element_by_link_text('销售统计').click()
        we = ['订单统计','地区统计','热销统计']
        for i in we:
            self.driver.find_element_by_link_text(i).click()
            time.sleep(2)
            for i in range(1,6):
                time.sleep(1)
                self.driver.find_element_by_id('datepick').click()
                self.driver.find_element_by_xpath('/html/body/div[3]/div[3]/ul/li[{}]'.format(i)).click()
        self.driver.find_element_by_link_text('会员分布统计').click()
        for i in range(1,6):
                time.sleep(1)
                self.driver.find_element_by_id('datepick').click()
                self.driver.find_element_by_xpath('/html/body/div[3]/div[3]/ul/li[{}]'.format(i)).click()
        self.driver.close()
        
        

if __name__ == '__main__':
    tes_tes()
